package com.smartmail.utility;

import java.util.Comparator;

import com.smartmail.mailing.MailMessage;

/**
 * Mail Message Comparator used to sort MailMessage objects.
 * 
 * @author Tomek
 *
 */
public class MailMessageComparator implements Comparator<MailMessage> {
	
	@Override
	public int compare(MailMessage lhs, MailMessage rhs) {
		
		if(lhs == null || rhs == null)
			return 0;
		
		if( lhs.getSentDate() == null || rhs.getSentDate() == null)
			return 0;
		else{
			return (lhs.getSentDate().compareTo(rhs.getSentDate())) * -1;
		}
	}

}
